package com.meilele.dao.czh;

import com.meilele.entity.czh.FiveCompany;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface FiveCompanyMapper {
    @Delete({
        "delete from five_company",
        "where company_id = #{companyId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer companyId);

    @Insert({
        "insert into five_company (company_id, company_name, ",
        "company_city, company_img, ",
        "company_logo, company_area, ",
        "company_style, company_motto, ",
        "company_award, company_type, ",
        "company_file)",
        "values (#{companyId,jdbcType=INTEGER}, #{companyName,jdbcType=VARCHAR}, ",
        "#{companyCity,jdbcType=VARCHAR}, #{companyImg,jdbcType=VARCHAR}, ",
        "#{companyLogo,jdbcType=VARCHAR}, #{companyArea,jdbcType=VARCHAR}, ",
        "#{companyStyle,jdbcType=VARCHAR}, #{companyMotto,jdbcType=VARCHAR}, ",
        "#{companyAward,jdbcType=VARCHAR}, #{companyType,jdbcType=VARCHAR}, ",
        "#{companyFile,jdbcType=VARCHAR})"
    })
    int insert(FiveCompany record);

    int insertSelective(FiveCompany record);

    @Select({
        "select",
        "company_id, company_name, company_city, company_img, company_logo, company_area, ",
        "company_style, company_motto, company_award, company_type, company_file",
        "from five_company",
        "where company_id = #{companyId,jdbcType=INTEGER}"
    })
    @ResultMap("com.meilele.dao.czh.FiveCompanyMapper.BaseResultMap")
    FiveCompany selectByPrimaryKey(Integer companyId);

    int updateByPrimaryKeySelective(FiveCompany record);

    @Update({
        "update five_company",
        "set company_name = #{companyName,jdbcType=VARCHAR},",
          "company_city = #{companyCity,jdbcType=VARCHAR},",
          "company_img = #{companyImg,jdbcType=VARCHAR},",
          "company_logo = #{companyLogo,jdbcType=VARCHAR},",
          "company_area = #{companyArea,jdbcType=VARCHAR},",
          "company_style = #{companyStyle,jdbcType=VARCHAR},",
          "company_motto = #{companyMotto,jdbcType=VARCHAR},",
          "company_award = #{companyAward,jdbcType=VARCHAR},",
          "company_type = #{companyType,jdbcType=VARCHAR},",
          "company_file = #{companyFile,jdbcType=VARCHAR}",
        "where company_id = #{companyId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(FiveCompany record);
    @Select({
            "select",
            "company_id, company_name, company_city, company_img, company_logo, company_area, ",
            "company_style, company_motto, company_award, company_type, company_file",
            "from five_company",
            "where company_city = #{companyCity,jdbcType=VARCHAR} limit ${firstPage}, ${resultPage}"
    })
    @ResultMap("com.meilele.dao.czh.FiveCompanyMapper.BaseResultMap")
    List<FiveCompany> selectByPrimaryCity(@Param("companyCity") String  companyCity,@Param("firstPage")int firstPage,@Param("resultPage") int resultPage);

    @Select({
            "select",
            "company_id, company_name, company_city, company_img, company_logo, company_area, ",
            "company_style, company_motto, company_award, company_type, company_file",
            "from five_company limit #{firstPage},#{resultPage}"
    })
    @ResultMap("com.meilele.dao.czh.FiveCompanyMapper.BaseResultMap")
    List<FiveCompany> findAll(@Param("firstPage")int firstPage,@Param("resultPage")int resultPage);

    @Select({
            "select",
            "Count(company_id) from five_company",
            "where company_city = #{companyCity,jdbcType=VARCHAR}"
    })
    int selectByPrimaryCount(String companyCity);

    @Select({
            "select",
            "Count(company_id) from five_company"
    })
    int findcon();

    @Select({
            "select",
            "company_id, company_name, company_city, company_img, company_logo, company_area, ",
            "company_style, company_motto, company_award, company_type, company_file",
            "from five_company "
    })
    @ResultMap("com.meilele.dao.czh.FiveCompanyMapper.BaseResultMap")
    List<FiveCompany> findAllcom();

}